from dose_stat import DoseStatRet, accumulate, get_metric, get_dose_stat_roi_interp

fn main():
    print("测试剂量统计库")
    print("================")
    
    # 测试数据
    var voxel_volume = [1.0, 2.0, 3.0, 4.0, 5.0]
    var voxel_dose = [10.0, 20.0, 30.0, 40.0, 50.0]
    
    print("\n1. 测试Accumulate函数...")
    var result = accumulate(voxel_volume, voxel_dose, False)
    
    print("   分箱剂量值数量:", len(result.binned_dose_values))
    print("   累积相对体积数量:", len(result.accumulated_relative_volumes))
    
    print("\n2. 测试GetMetric函数...")
    var d98 = get_metric(0.98, result.binned_dose_values, result.accumulated_relative_volumes)
    print("   D_98 =", d98, "Gy")
    
    var d95 = get_metric(0.95, result.binned_dose_values, result.accumulated_relative_volumes)
    print("   D_95 =", d95, "Gy")
    
    var d50 = get_metric(0.5, result.binned_dose_values, result.accumulated_relative_volumes)
    print("   D_50 =", d50, "Gy")
    
    print("\n3. 测试GetDoseStatRoiInterp函数...")
    var average_dose = get_dose_stat_roi_interp(
        "average", result.binned_dose_values, result.accumulated_relative_volumes,
        voxel_volume, voxel_dose
    )
    print("   平均剂量 =", average_dose, "Gy")
    
    var d95_alt = get_dose_stat_roi_interp(
        "D_95", result.binned_dose_values, result.accumulated_relative_volumes,
        voxel_volume, voxel_dose
    )
    print("   D_95 (via interp) =", d95_alt, "Gy")
    
    var dose_at_70 = get_dose_stat_roi_interp(
        "DoseAtVolume", result.binned_dose_values, result.accumulated_relative_volumes,
        voxel_volume, voxel_dose, 0.7
    )
    print("   70%体积处的剂量 =", dose_at_70, "Gy")
    
    print("\n测试完成!")